// 跟文章相关的接口
import { $http } from "@/utils";

// 1.获取文章频道列表
export function getChannelAPI() {
  return $http({
    url: "/channels",
    method: "GET",
  });
}

// 2.文章表单提交

export function createArticeAPI(data) {
  return $http({
    url: "/mp/articles?draft=false",
    method: "POST",
    data,
  });
}

// 3.获取文章列表

export function getArticleListAPI(params) {
  return $http({
    url: "/mp/articles",
    method: "GET",
    params,
  });
}

// 4.删除文章列表
export function delArticleAPI(id) {
  return $http({
    url: `mp/articles/${id}`,
    method: "DELETE",
  });
}

// 5.使用id获取当前数据
export function getArticleByIdAPI(id) {
  return $http({
    url: `mp/articles/${id}`,
    method: "GET",
  });
}

// 6.根据id 更新修改当前数据
export function uploadArticleAPI(data) {
  return $http({
    url: `mp/articles/${data.id}?draft=false`,
    method: "PUT",
    data,
  });
}
